int duplicateInArray(int *nums, int numsSize){
    for (int i = 0; i < numsSize-1; i++)
        if (*(nums + i) >= numsSize || *(nums + i) < 0 || numsSize == 0)
            return -1;
    for (int i = 0; i < numsSize-1; i++)
        for (int j = i+1; j < numsSize; j++) 
            if (*(nums + j) == *(nums + i))
                 return *(nums+i);
    return -1;
}